function queryDetail(name) {
    $.ajax({
        type:'GET',
        url:'/rest/front/product/selectAllSearchList',
        data:{name:name},
        dataType:'json',
        success:function (data) {
            var list=data.data,html='';
            $('.j-search').html();
           if(list!=null&&list!=''){
               $.each(list,function (i, e) {
                   html+='<li data-id="'+e.id+'" data-type="'+e.code+'"><h5>'+e.name+'</h5><p>'+e.introduce+'</p></li>'
               });
               $('.j-search').html(html);
               $(".j-search p").each(function () {
                   var maxwidth =120;
                   if ($(this).text().length > maxwidth) {
                       $(this).text($(this).text().substring(0, maxwidth));
                       $(this).html($(this).html() + '...');
                   }
               });
                $(".j-search li").click(function(){
                 var type=$(this).attr('data-type'),
                     id=$(this).attr('data-id');
                 if(type=='1'){
                     window.location.href="../cpzx/cpxl/"+id+".html";
                 }else if(type=='2'){
                     window.location.href="../../../jjfa.html?categoryID="+id;
                 }else {
                     window.location.href="../zlkx/"+id+".html";
                 }
             })
           }else{
            $('.lack').show()
           }
        }
    })
}
$(function () {
    var postData = GetRequest();
    var name = postData.name||'产品';
    queryDetail(name);
    $('.search-btn').click(function () {
        var name=$('#searchInput').val()||$('#searchInput1').val();
        queryDetail(name);
    })
});